﻿namespace Cos.Core.NHibernate
{
    #region Usings

    using System;

    using Cos.Core.Model.Common;

    #endregion

    public class CultureDataModel : DataModelBase<Culture>
    {
        #region Constructors and Destructors

        public CultureDataModel()
        {
            this.Id = string.Empty;
        }

        #endregion

        #region Properties

        public virtual string Id { get; set; }

        public virtual string CultureDesc { get; set; }
        
        public virtual bool IsDefault { get; set; }

        #endregion

        #region Object Overrides

        public override bool Equals(object obj)
        {
            if (obj == null)
            {
                return false;
            }

            var model = obj as CultureDataModel;

            return model != null && this.Id == model.Id;
        }

        public override int GetHashCode()
        {
            return this.Id.GetHashCode();
        }

        #endregion

        #region Public Methods

        public override void Fill(Culture model)
        {
            this.Id = model.CultureCode;
            this.CultureDesc = model.CultureDesc;
            this.IsDefault = model.IsDefaultCulture;
        }

        public override Culture ToModel()
        {
            var model = new Culture();

            model.CultureCode = this.Id;
            model.CultureDesc = this.CultureDesc;
            model.IsDefaultCulture = this.IsDefault;

            return model;
        }

        #endregion
    }
}